// My Panel Script
//Recognition to: Chris Biblis
//Internal Functions go here.
 
function removeCommas(str) {
   return str.replace(/,/g, "");
}; 
  
function cardswap(){	
	var bsu=get_value("bosu");
		if (bsu==1){learn();}
			else if (bsu==2){ sell();}
			else if (bsu==3){ upgrade();}
		return false;};
		
function learn(){

	var cardt=get_value("cid");
	var camt=get_value("card_count");
		KN_NAVIGATION.requestPage("abilities_handle",function(){return false;},{"action":"learn", "cID":cardt,"amt":camt});
	return false;}

function sell(){
	var cardt=get_value("cid");
	var camt=get_value("card_count");
		KN_NAVIGATION.requestPage("abilities_handle",function(){return false;},{"action":"unlearn", "cID":cardt,"amt":camt});
	return false;}
 
function upgrade(){
	var cardt=get_value("cid");
	var camt=get_value("card_count");
		KN_NAVIGATION.requestPage("upgrade_handle",function(){return false;},{"action":"upgrade", "cID":cardt,"amt":camt});
	return false;}
	
 
function FJaddItem(){
		var e2=document.getElementById('training_count_4');
		var o=document.createElement('option');
		o.value=1000;
		o.text=1000;
		e2.options.add(o);}


/////////////////////////////////////// SUPPORT FUNCTIONS ////////////////////////////////////////////
function FJdisplayDiv(){
        var divstyle = new String();
        divstyle = document.getElementById("hidden_training").style.display;
        if(divstyle.toLowerCase()=="block" || divstyle == "")
        {
        document.getElementById("hidden_training").style.display = "none";
        }
        else
        {
        document.getElementById("hidden_training").style.display = "block";
        }
}
function FJdisplayDiv2(){
        var divstyle = new String();
        divstyle = document.getElementById("hidden_training2").style.display;
        if(divstyle.toLowerCase()=="block" || divstyle == "")
        {
        document.getElementById("hidden_training2").style.display = "none";
        }
        else
        {
        document.getElementById("hidden_training2").style.display = "block";
        }
}

function dget(e){ return document.getElementById(e);}

function get_value(n){
	e=document.getElementById(n);
	if ((e.value)&&(e.value != "")&&(!e.options)) return e.value; if ((e.selectedIndex)&&(e.selectedIndex>0) &&(e.options[e.selectedIndex].value !="")) return e.options[e.selectedIndex].value; return false;
	}